// part1:C10:ex10.3.cpp
// use accumulate to get sum of elements of vector<int>.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
  ifstream in(argv[1]);
  if (!in) {
    cout << "failed to open input file!" << endl; 
    exit(1);
  }

  vector<int> v;
  int val;
  while (in >> val) {
    v.push_back(val);
  }
  cout << "sum of sequence is : " << accumulate(v.begin(), v.end(), 0) << endl;

  return 0;
}
